package algotithm.leetcode.dichotomy.test852;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/8-11:52
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] arr = {0,2,1,0};
        int array = solution.peakIndexInMountainArray(arr);
        System.out.println(array);
    }


    public int peakIndexInMountainArray(int[] arr) {
        int i = 0, j = arr.length - 1;
        while (i < j) {
            int mid = i + j >> 1;
            if (arr[mid] < arr[mid+1]) {
                i = mid + 1;
            } else {
                j = mid ;
            }
        }
        return i;
    }


}
